﻿//-----------------------------------------------------------------------
// <copyright file="TemplateGroupHelper.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings

using System;
using FastNET.CleanAct.Common.Repository;
using FastNET.CleanAct.Common.Repository.Interfaces.DataInterfaces.ManagementEngine;
using FastNET.CleanAct.Common.Repository.Interfaces.Repositories.ManagementEngine;
using TemplateGroup = FastNET.CleanAct.Client.ManagerEngineData.Entities.TemplateGroup;

#endregion

namespace FastNET.CleanAct.Testing.Client.ManagerEngineData.Helpers
{
    /// <summary>
    /// Static Unit Test Helper Class for TemplateGroup Entities
    /// </summary>
    internal static class TemplateGroupHelper
    {
        /// <summary>
        /// Creates an ITemplateGroupData ready to save to the database
        /// </summary>
        /// <returns>ITemplateGroupData with unique default values</returns>
        public static ITemplateGroupData Create()
        {
            return Create(Guid.NewGuid(), Guid.NewGuid());
        }

        /// <summary>
        /// Creates an ITemplateGroupData ready to save to the database
        /// </summary>
        /// <param name="primaryTemplateID">Primary TemplateID to associate the item with</param>
        /// <param name="secondaryTemplateID">Secondary TemplateID to associate the item with</param>
        /// <returns>ITemplateGroupData with unique default values</returns>
        public static ITemplateGroupData Create(Identity primaryTemplateID, Identity secondaryTemplateID)
        {
            ITemplateGroupData item = new TemplateGroup();

            item.ParentTemplateID = primaryTemplateID;
            item.ChildTemplateID = secondaryTemplateID;

            return item;
        }

        /// <summary>
        /// Creates an ITemplateGroupData ready pre-saved to the database
        /// </summary>
        /// <returns>ITemplateGroupData with unique default values</returns>
        public static ITemplateGroupData CreateDB()
        {
            return CreateDB(TemplateHelper.CreateDB().ID, TemplateHelper.CreateDB().ID);
        }

        /// <summary>
        /// Creates an ITemplateGroupData ready pre-saved to the database
        /// </summary>
        /// <param name="primaryTemplateID">Primary TemplateID to associate the item with</param>
        /// <param name="secondaryTemplateID">Secondary TemplateID to associate the item with</param>
        /// <returns>ITemplateGroupData with unique default values</returns>
        public static ITemplateGroupData CreateDB(Identity primaryTemplateID, Identity secondaryTemplateID)
        {
            TemplateGroup item = (TemplateGroup)Create(primaryTemplateID, secondaryTemplateID);

            DBHelper.Provider.GetRepository<ITemplateGroupRepository>().Save(item);

            return item;
        }
    }
}
